package com.example.wuqujingdianphone.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;


import java.util.List;

/**
 * Created by yuanpk on 2018/4/10.
 */

public class BookShopPagerAdapter extends FragmentPagerAdapter {// 注意：使用 FragmentStatePagerAdapter 时，使用现在的懒加载时会出问题的。

    private List<Fragment> fragmentList;
    private List<String> titles;


    public BookShopPagerAdapter(FragmentManager fm, List<String> titles, List<Fragment> fragmentList) {
        super(fm);
        this.titles = titles;
        this.fragmentList = fragmentList;
        //fragmentList.add(BRBookFragment.getBRBookFragment());
        //fragmentList.add(BRListenBookFragment.getBRListenBookFragment());

    }


    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }
}
